﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DAL;
public partial class TypeInfoUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            databind();
        }
    }
    private void databind()
    {
        int typeid = Convert.ToInt32(Request.QueryString["id"]);

        using (DataClassesDataContext lqDB = new DataClassesDataContext())
        {
            TypeInfo type = lqDB.TypeInfo.FirstOrDefault(t => t.Type_ID == typeid);
            this.txtTypeIDs.Text = Convert.ToString(type.Type_ID);
            this.txtTypeNames.Text = type.Type_Name;
        }
    }
    private void update()
    {
        int typeid = Convert.ToInt32(txtTypeIDs.Text);
        using (DataClassesDataContext lqDB = new DataClassesDataContext())
        {
            TypeInfo type = lqDB.TypeInfo.FirstOrDefault(t => t.Type_ID == typeid);
            type.Type_Name = txtTypeNames.Text;
            lqDB.SubmitChanges();
            Frame.Global.GlobalFunctions.AlertToUrl("修改成功！", "EditProTypeInfo.aspx");
        }
    }
    protected void btnOK1_Click(object sender, EventArgs e)
    {
        update();
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("EditProTypeInfo.aspx");
    }
}